// 多态
function mixin( sourceObj, targetObj ) { 
    for (var key in sourceObj) { 
    // 只会在不存在的情况下复制
    if (!(key in targetObj)) { 
    targetObj[key] = sourceObj[key]; // 避免覆盖原有属性
    } 
    } 
    return targetObj; 
   } 
   // 由于两个对象引用的是同一个函数，因此这种复制（或者说混入）实际上并不能完全模拟
//面向类的语言中的复制。
   var Vehicle = { 
    engines: 1, 
    ignition: function() { 
    console.log( "Turning on my engine." ); 
    }, 
    drive: function() { 
    this.ignition(); 
    console.log( "Steering and moving forward!" ); 
    } 
   }; 
   var Car = mixin( Vehicle, { 
    wheels: 4, 
    drive: function() { 
    Vehicle.drive.call( this ); 
    console.log( 
    "Rolling on all " + this.wheels + " wheels!" 
    ); 
    } 
   } );